home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 24 / MacFormat n. 24 (Spain) / MacFormat 24.bin / Shareware / Programación / C-Strip 1.0.5 ƒ / Sample.c < prev   
Encoding:
C/C++ Source or Header  |  1994-07-24  |  2.7 KB  |  92 lines

  1. /***************************************************************
  2.  
  3.     Sample.c
  4.  
  5.     Written by Jefferson Quade
  6.     ©1993-1994 Quade Publishing Company, Box 1574, Fort Dodge, Iowa 50501
  7.  
  8.     Created Sunday, August 8, 1993 04:40 PM
  9.  
  10. ***************************************************************/
  11.  
  12. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  13.     Include files.
  14. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  15.  
  16. #ifndef _H_MacHeaders
  17. #include <MacHeaders>
  18. #endif
  19.  
  20. #include <QLibrary.h>
  21. #include "Chess.h"
  22.  
  23. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  24.     Private prototypes.
  25. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  26.  
  27. static void ChessUtilitiesRoutines (void);
  28.  
  29. /*=========================================================================
  30.  
  31. =========================================================================*/
  32.  
  33. static void ChessUtilitiesRoutines (void)
  34. {
  35. //• Declared static with no arguments, save the 6 bytes on the stack frame.
  36.     asm
  37.     {
  38. /*=========================================================================
  39.     Returns true if the game square is white.
  40. =========================================================================*/
  41.  
  42.     //• Object size 24 bytes.
  43.     extern SquareIsWhite:    ; Assembly language is small and fast!
  44.         move.w 4(sp), d1    // Square number.
  45.         subq.w #1, d1         // Shift numbers down one.
  46.         btst #0, d1             // See if even or odd number.
  47.         sne d0                     // If odd number then white square.
  48.         btst #3, d1             // See if even or odd column.
  49.         beq.s @1                 // If odd column return.
  50.         tst.b d0
  51.         seq d0                     // Toggle result.
  52.     @1: return
  53.     }
  54. }
  55.  
  56. /*=========================================================================
  57.     Returns true if the game square is white.
  58. =========================================================================*/
  59.  
  60. #if 0
  61.  
  62. //• Object size 44 bytes.
  63. Boolean SquareIsWhite(short c)
  64. {
  65.     Boolean result;
  66.  
  67.     --c;
  68.     result = bittst(0, c);
  69.     if (bittst(3, c)) result = !result;
  70.     return result;
  71. }
  72.  
  73. #endif
  74.  
  75. /*=========================================================================
  76.     Returns true if the square is white.
  77. =========================================================================*/
  78.  
  79. #if 0
  80.  
  81. //• Object size 406 bytes - very slow!
  82. Boolean SquareIsWhite(short c)
  83. {
  84.     if (c == 2 | c == 4 | c == 6 | c == 8 | c == 9 | c == 11 | c == 13 |
  85.         c == 15 | c == 18 | c == 20 | c == 22 | c == 24 | c == 25 | c == 27 |
  86.         c == 29 | c == 31 | c == 34 | c == 36 | c == 38 | c == 40 | c == 41 |
  87.         c == 43 | c == 45 | c == 47 | c == 50 | c == 52 | c == 54 | c == 56 |
  88.         c == 57 | c == 59 | c == 61 | c == 63) return true;
  89.     return false;
  90. }
  91.  
  92. #endif